package com.fg.common.exception;

import com.fg.common.response.Response;
import com.fg.common.response.ResponseCodeConstant;

/**
 * 自定义异常
 * @author lv
 * @version 1.0.0
 */
public class FgException extends RuntimeException implements Response {

    /**
     * 状态码
     */
    private String code;

    /**
     * 描述信息
     */
    private String message;

    /**
     * 无参构造
     */
    public FgException(String message){
        this.code = ResponseCodeConstant.UNKNOWN;
        this.message = message;
    }

    /**
     * 构造自定义异常
     * @param response 统一响应枚举对象
     */
    public FgException(Response response){
        this.code = response.getCode();
        this.message = response.getMessage();
    }

    public FgException(String code, String message){
        this.code = code;
        this.message = message;
    }


    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
